package com.ygqh.baby.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.mapper.WdtQybLogisticsMapper;
import com.ygqh.baby.model.wdt.qyb.WdtSyncLogistics;
import com.ygqh.baby.po.WdtQybLogistics;
import com.ygqh.baby.po.WdtQybLogisticsExample;
import com.ygqh.baby.service.WdtQybLogisticsService;

@Service
public class WdtQybLogisticsServiceImpl implements WdtQybLogisticsService {

	@Autowired
	private WdtQybLogisticsMapper wdtQybLogisticsMapper;

	@Override
	public List<WdtQybLogistics> find() {
		WdtQybLogisticsExample example = new WdtQybLogisticsExample();
		example.createCriteria();
		return wdtQybLogisticsMapper.selectByExample(example);
	}

	@Override
	public int findCount() {
		WdtQybLogisticsExample example = new WdtQybLogisticsExample();
		example.createCriteria();
		return wdtQybLogisticsMapper.countByExample(example);
	}

	@Override
	public WdtQybLogistics findById(Integer id) {
		return wdtQybLogisticsMapper.selectByPrimaryKey(id);
	}

	@Override
	public int save(WdtQybLogistics wdtQybLogistics) {
		return wdtQybLogisticsMapper.insertSelective(wdtQybLogistics);
	}

	@Override
	public int update(WdtQybLogistics wdtQybLogistics) {
		return wdtQybLogisticsMapper.updateByPrimaryKeySelective(wdtQybLogistics);
	}

	@Override
	public ResultSet<WdtQybLogistics> search(QueryInfo queryInfo, String q) {
		List<WdtQybLogistics> list = wdtQybLogisticsMapper.selectSuper(queryInfo, q);
		int count = wdtQybLogisticsMapper.countSuper(q);
		ResultSet<WdtQybLogistics> resultSet = new ResultSet<WdtQybLogistics>(count, list);
		return resultSet;
	}

	@Override
	public int saveOrUpdate(WdtQybLogistics wdtQybLogistics) {
		int r = 0;
		if (wdtQybLogistics.getRecId() != null) {
			r = this.update(wdtQybLogistics);
		} else {
			r = this.save(wdtQybLogistics);
		}
		return r;
	}

	@Override
	public int addBatch(List<WdtSyncLogistics> list) {
		if (CollectionUtils.isEmpty(list)) {
			return 0;
		}
		return wdtQybLogisticsMapper.addBatch(list);
	}

	@Override
	public List<WdtSyncLogistics> findKidsListAfterId(int id) {
	
		return wdtQybLogisticsMapper.selectKidsListAfterId(id);
	}

}
